-
Notifications
You must be signed in to change notification settings - Fork 32
add GATT server database cache support #341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zhongzhijie1
wants to merge
14
commits into
open-vela:dev
Choose a base branch
from
zhongzhijie1:gatt_service_cache
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1fa9426 to
26a60a3
Compare
558c139 to
13d0d73
Compare
support. bug: v/65087 Signed-off-by: zhongzhijie1 <[email protected]>
…global database hash. bug :v/65095 The logic is implemented in gatts_service.c to trigger hash calculation and return the result via a registered callback, for trusted device sync and DB change tracking. Signed-off-by: zhongzhijie1 <[email protected]>
…h from adapter to profile. bug: v/65126 Root cause: Adapter had no generic message path to deliver events to profile services. GATTS could not receive a request to fetch the server database hash. Add adapter handler to forward profile_msg_t to service_manager. Add PROFILE_EVT_GATTS_REQUEST_DB_HASH and handle it in gatts_service via process_msg. Wire bt_sal_gatt_server_get_database_hash() call when the event is received. Signed-off-by: zhongzhijie1 <[email protected]>
bug: v/65129 Root cause: The stack did not compute and store the server GATT database hash on initial bonding. Peers could keep a stale GATT cache because no hash update was triggered. When a bonded LE device is connected, send PROFILE_EVT_GATTS_REQUEST_DB_HASH. Force hash update to start cache sync for the new bond. Signed-off-by: zhongzhijie1 <[email protected]>
bug: v/65131 There was no persistent storage for the server GATT database hash. The system could not compare hashes after reboot and peers could keep a stale GATT cache. Add remote_device_gatt_properties_t with 16-byte hash field. Add save/load APIs for GATT hash cache using the uv_db backend (BT_KEY_BLEGATTHASH). Signed-off-by: zhongzhijie1 <[email protected]>
bug: v/65135 KVDB backend had no key and no save/load path for GATT server database hash. The system could not restore the hash after reboot and cache validation failed. Add BT_KVDB_BLEGATTDBHASH and helpers to save/load remote_device_gatt_properties_t entries. Count and delete old hash properties before saving new data. Signed-off-by: zhongzhijie1 <[email protected]>
bug: v/65139 The device object had no field to keep the GATT database hash. The stack could not persist and validate GATT cache state per bonded peer. Add a 16-byte gatt_hash field under CONFIG_BLUETOOTH_GATTS_CACHE_SUPPORT. Add get/set/delete helpers and export remote_device_gatt_properties_t data. Add DFLAG_GATT_HASH_VALID to mark hash presence. Signed-off-by: zhongzhijie1 <[email protected]>
bug: v/65142 Adapter did not load or persist the per-device GATT database hash state. After reboot or unpair, the stack lost hash data and cache validation became unreliable. Load GATT hash entries on LE enable and restore them into device objects. Save updated hash list when bond state changes and clear hash on unpair. Use bt_storage_load_gatt_cache_device and bt_storage_save_gatt_cache_device under CONFIG_BLUETOOTH_GATTS_CACHE_SUPPORT. Signed-off-by: zhongzhijie1 <[email protected]>
as gatts_service. bug: v/65146 gatts_service could not access the adapter device database to read or update the stored GATT database hash. Hash update and persistence were handled inside adapter_service only, so other modules could not drive cache sync. Add adapter_get_device_gatt_hash() and adapter_set_device_gatt_hash() under CONFIG_BLUETOOTH_GATTS_CACHE_SUPPORT. Only allow bonded devices and keep a zero hash when no valid hash is present. Avoid duplicate db hash requests when DFLAG_GATT_HASH_VALID is already set. Signed-off-by: zhongzhijie1 <[email protected]>
bug: v/65160 The server did not track the peer-synced GATT database hash. Peers could keep a stale GATT cache and the stack could not detect a database change. Request the latest database hash on GATT connection. On hash event, compare with the stored value and decide the next action. Update the stored hash after handling the event. Compile the feature under CONFIG_BLUETOOTH_GATTS_CACHE_SUPPORT. Signed-off-by: zhongzhijie1 <[email protected]>
bug: v/65182 Add bt_sal_gatt_server_change_indicate(start_hdl, end_hdl) with parameter validation. Use the new SAL API from gatts_service when a hash mismatch is detected. Signed-off-by: zhongzhijie1 <[email protected]>
bug: v/65203 Signed-off-by: zhongzhijie1 <[email protected]>
bug: v/65131 Since the current version_5_0_3 has no business logic and does not impact the existing storage structure, the GATT hash is reused in version_5_0_3. New GATT hash items added in version_5_0_3 include: 1. Added enumeration value: BT_STORAGE_UPDATE_GATT_HASH_INFO 2. Added GATT hash removal logic within the bt_storage_properties_destroy function 3. Modified the bt_storage_update_item_size table 4. Added GATT hash items to the callback_cnt_list 5. Added GATT_cache save logic to the bt_storage_update_save_info function Signed-off-by: liuxiang18 <[email protected]>
bug: v/65182 Signed-off-by: zhongzhijie1 <[email protected]>
13d0d73 to
289678c
Compare
liuX10
approved these changes
Jan 9, 2026
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds GATT server database cache support to improve BLE reconnection experience with bonded devices. The implementation allows the stack to track GATT attribute table changes and notify peers via Service Changed indications when the database hash differs.
Changes
CONFIG_BLUETOOTH_GATTS_CACHE_SUPPORTKconfig option to enable/disable the featureBT_KEY_BLEGATTHASH)remote_device_gatt_properties_tstructureTechnical Details
Testing